/***************************************************************
 * @System            : 生鲜系统
 * @Content           : 继承 ToolTipController，增加相关通用方法或事件
 * @Author            : geping  2017-02-06
 * @Modify            : 
 * @Version           : v1.0
 * @Copyright         : 宁波康铭泰克信息科技有限公司
 ***************************************************************/

using System.ComponentModel;
using System.Windows.Forms;
using DevExpress.Utils;

namespace Comteck.Winforms.Controls {
  /// <summary>
  /// 
  /// </summary>
  [ToolboxItem(true)]
  public partial class MyToolTipController : ToolTipController {
    #region 构造函数

    /// <summary>
    /// 默认构造
    /// </summary>
    public MyToolTipController() : base() {
    }
  

    #endregion

    /// <summary>
    /// 冒泡提示
    /// </summary>
    /// <param name="control">目标控件，在其上面提示显示</param>
    /// <param name="content">提示的信息，默认：???</param>
    /// <param name="title">提示的标题，默认：温馨提示</param>
    /// <param name="tipIconType">显示框图表的类型</param>
    /// <param name="showTime">提示显示等待时间，默认：2000ms</param>
    /// <param name="isAutoHide">是否自动隐藏提示信息</param>
    /// <param name="toolTipType">显示的类型</param>
    /// <param name="tipLocation">在控件显示的位置</param>
    /// <param name="imgList">装载Icon图标的List，显示的ToolTipIconType上，可以为Null</param>
    /// <param name="imgIndex">图标在ImageList上的索引，ImageList为Null时传0进去</param>
    public void ShowToolTip(Control control, string content, string title = null, ToolTipIconType tipIconType = ToolTipIconType.Information,
        int showTime = 0, bool isAutoHide = true, ToolTipType toolTipType = ToolTipType.Default,
        ToolTipLocation tipLocation = ToolTipLocation.Default, ImageList imgList = null, int imgIndex = 0) {
      // 创建实例
      ToolTipControllerShowEventArgs args = this.CreateShowArgs();
      content = string.IsNullOrWhiteSpace(content) ? "???" : content;
      title = string.IsNullOrWhiteSpace(title) ? "温馨提示" : title;
      this.ImageList = imgList;
      this.ImageIndex = imgList == null ? 0 : imgIndex;
      args.AutoHide = isAutoHide;
      this.ShowBeak = true;   // 自动断行
      this.ShowShadow = true;   // 显示阴影
      this.Rounded = true;   // 圆角 
      this.AutoPopDelay = (showTime == 0 ? 2000 : showTime);  // 延时显示时间
      this.SetToolTip(control, content);
      this.SetTitle(control, title);
      this.SetToolTipIconType(control, tipIconType);
      this.Active = true;
      this.HideHint();
      this.ShowHint(content, title, control, tipLocation);
    }
  }
}
